<template>
  <el-main>
    <el-card style="margin-bottom: 20px; display: flex; align-items: center">
      <!-- 查询条件 -->
      <el-form :model="searchModel" ref="searchForm" label-width="80px" :inline="true" style="display: flex; align-items: center">
        <el-form-item>
          <el-input v-model="searchModel.roleName" placeholder="请输入角色名称" />
        </el-form-item>
        <el-form-item>
          <el-button type="primary" round icon="el-icon-search">查询</el-button>
          <el-button type="primary" round icon="el-icon-plus" @click="">新增</el-button>
        </el-form-item>
      </el-form>
    </el-card>

    <!-- 数据表格 -->
    <!-- <el-table
      :data="tableData"
      :height="tableHeight"
      style="width: 100%; margin-top: 20px;"
      row-key="id"
      border
      default-expand-all
      :tree-props="{children: 'children'}"
    >
      <el-table-column prop="label" label="权限名称" align="center"></el-table-column>
      <el-table-column prop="content" label="权限内容" align="center"></el-table-column>
      <el-table-column label="操作" align="center">
          <el-button type="danger" size="small" icon="el-icon-delete">删除</el-button>
      </el-table-column>
    </el-table> -->

    <!-- 数据表格 -->

    <el-table
      default-expand-all
      :tree-props="{ children: 'children' }"
      stripe
      :data="tableData"
      style="width: 100%; margin-bottom: 10px; text-align: center"
    >
      <!-- <el-table-column prop="No" label="序号" width="80" align="center" header-align="center">
        <template slot-scope="scope">
          {{ (permission.pageNo - 1) * permission.pageSize + permission.$index + 1 }}
        </template>
      </el-table-column> -->
      <el-table-column prop="pid" label="角色id" width="auto" align="center" header-align="center"></el-table-column>
      <el-table-column prop="label" label="标签" width="auto" align="center" header-align="center"></el-table-column>
      <el-table-column prop="parentid" label="父节点id" width="auto" align="center" header-align="center"></el-table-column>
      <el-table-column prop="parent_name" label="父节点名称" width="auto" align="center" header-align="center"></el-table-column>
      <el-table-column prop="path" label="路径" width="auto" align="center" header-align="center"></el-table-column>
      <el-table-column prop="name" label="名称" width="auto" align="center" header-align="center"></el-table-column>
      <el-table-column prop="url" label="url" width="auto" align="center" header-align="center"></el-table-column>

      <el-table-column label="操作" width="auto" align="center" header-align="center" fixed="right">
        <template slot-scope="scope">
          <!-- <el-button icon="el-icon-setting" type="primary" size="small" @click="">分配权限</el-button> -->
          <el-button icon="el-icon-edit" type="primary" size="small" @click="">修改</el-button>
          <!-- <el-button icon="el-icon-delete" type="danger" size="small" @click="">删除</el-button> -->
        </template>
      </el-table-column>
    </el-table>
    <!-- 分页工具栏 -->
    <el-pagination
      :current-page.sync="permission.pageNo"
      :page-sizes="[5, 10, 20, 50]"
      :page-size="permission.pageSize"
      layout="total, sizes, prev, pager, next, jumper"
      :total="permission.total"
      style="margin-top: 15px"
      @size-change="perSizeChange"
      @current-change="perCurrentChange"
    />

    <!-- 新增弹窗
    <el-dialog :visible.sync="dialogFormVisible" :title="title" center @close="closeAddUI">
      <el-form :model="permissionForm">
        <el-form-item label="权限名称" label-width="100px">
          <el-input v-model="roleForm.name" autocomplete="off" placeholder="请输入角色名称" />
        </el-form-item>
      </el-form>

      <template #footer>
        <span class="dialog-footer">
          <el-button type="primary" @click="roleAdd(roleForm)">确定</el-button>
          <el-button @click="dialogFormVisible = false">取消</el-button>
        </span>
      </template>
    </el-dialog> -->
  </el-main>
</template>

<script>
import permissionApi from '@/api/permission'
export default {
  name: 'index',
  data() {
    return {
      dialogFormVisible: false,
      searchModel: [],
      permission: {
        pageNo: 1,
        pageSize: 5,
        total: 1,
      },
      tableData: [],
    }
  },
  //初始化时调用
  created() {
    this.getPerList()
  },
  mounted() {
    this.$nextTick(() => {
      this.tableHeight = window.innerHeight - 180
    })
  },
  methods: {
    getPerList() {
      permissionApi.getPerList().then((response) => {
        this.tableData = response.e
        this.tableData.children = response.e.children
      })
    },
    perSizeChange() {},
    perCurrentChange() {},
    /*
    打开新增的窗口
     */
    openAddWindow() {},
  },
}
</script>

<style scoped>
</style>
